new Vue({
    el: '#app',
    data: {
        total: 0,
        pageIndex: 1,
        pageSize: 10,
        pageCon: 1,
        msg: '',
        member: {},
        prizeList: [],
        SERVER_HOST: SERVER_HOST
    },
    mounted() {
        var member = Cookies.get('member');
        if (!member || member == null || member == '') {
            window.location.href = 'dl.html';
        } else {
            this.member = JSON.parse(member);
            this.loadPrize();
        }
    },
    methods: {
        exit() {
            Cookies.remove('member');
            window.location.href = 'dl.html';
        },
        loadPrize () {
            let formData = {};
            formData['page'] = this.pageIndex;
            formData['size'] = this.pageSize;
            for (var key in this.member) {
                formData[key] = this.member[key];
            }
            getAjax().post('/web/prizesByMember', toFormData(formData)).then(res => {
                if (res.data.data) {
                    this.prizeList = res.data.data.list;
                    this.total = res.data.data.total;
                    this.pageCon = Math.ceil(this.total / this.pageSize);
                    this.prizeList.forEach(item => {
                        item.createtime = getDate(item.createtime);
                    })
                }
            });
        },
        pageSelect (pageIndex) {
            if (pageIndex < 1 || pageIndex > this.pageCon) return;
            this.pageIndex = pageIndex;
            this.loadPrize();
        }
    }
});
